(function(){
	angular.module('app').component('tableListComponent',{
		templateUrl:'app/components/table.list.component/table.list.component.html',
		controller: tableListComponent,
		controllerAs: 'vm',
		bindings:{
			tabSeen: '=',
			tabOnly: '<' 
		}
	});

	tableListComponent.$inject = ['tableListComponentService','$rootScope','$scope'];

	function tableListComponent(tableListComponentService,$rootScope,$scope){
		var vm = this;
		// console.log('tableProdsListComponent js');

		vm.title = ''; //标题
		vm.type = '';//展示类型  shop or brand

		//只有品牌数据才有tab标签页
		vm.tab = 'shop';

		// vm.tabSeen tab是否展示
		// vm.tabOnly tab show close 没有多级tab
		vm.goBack = goBack;//function
	

		// console.log('==============');console.log(vm.tabSeen);

		//店铺数据
		var clearShopEV = $rootScope.$on('formShop_detail_EV',function(e,shopId,shopName){
			// console.log('----formShop_detail_EV---shopId:'+shopId);
			vm.title = shopName+'商品数据';
			vm.type = 'shop';
			vm.tabSeen = true;
		});

		//品牌数据
		var clearBrandEV = $rootScope.$on('formBrand_detail_EV',function(e,brandName){
			// console.log('---formBrand_detail_EV---brandName:'+brandName);
			vm.tabSeen = true;
			vm.title = brandName+'品牌数据';
			vm.type = 'brand';
			vm.tab = 'shop';//品牌shop标签页
		});

		//品牌店铺商品数据
        var clearBrandShopEV = $rootScope.$on('formBrandShop_detail_EV', function(e, shopId,shopName) {
         	// console.log('formBrandShop_detail_EV -shopName:'+shopName);
            vm.title = shopName+'商品数据';
			vm.type = 'brandshop';
			vm.tabSeen = true;
            
        });

        // 品牌中的店铺中的商品数据goBack
        function goBack(){
        	// console.log('tab09');
        	if(vm.tabOnly){ //只有一级
        		
        		vm.tabSeen = false;
        	}else{//多级
        		vm.type = 'brand';        		
        	}
        	
        }

		$scope.$on('$destroy',function(){
			clearShopEV();
			clearBrandEV();
			clearBrandShopEV();
		});
	}
})();